def get_ratings(type, incomplete_tasks, incomplete_deliverables, objectives):
    badTasksCount = 0 
    for task in incomplete_tasks:
      if task.is_overdue():
        badTasksCount = badTasksCount + 1
    if incomplete_tasks.count() > 0: 
      tasksRating = -round((float(badTasksCount) / float (incomplete_tasks.count())) * 100, 0)
    else:
      tasksRating = 0

    badDeliverablesCount = 0
    goodDeliverablesCount = 0
    for deliverable in incomplete_deliverables:
      if deliverable.is_overdue():
        badDeliverablesCount = badDeliverablesCount + 1
      elif deliverable.completed_date:
        goodDeliverablesCount = goodDeliverablesCount + 1
    if incomplete_deliverables.count() > 0: 
      deliverablesRating = round((float(goodDeliverablesCount - badDeliverablesCount) / float (incomplete_deliverables.count())) * 100, 0)
    else:
      deliverablesRating = 0

    badObjectivesCount = 0
    goodObjectivesCount = 0
    combined_status = 0
    for objective in objectives:
      if objective.is_behind_schedule():
        badObjectivesCount = badObjectivesCount + 1
      elif objective.is_ahead_of_schedule():
        goodObjectivesCount = goodObjectivesCount + 1
      combined_status = combined_status + objective.status() 
    if objectives.count() > 0:  
      objectivesRating = round((float(goodObjectivesCount - badObjectivesCount) / float (objectives.count())) * 100, 0)
      average_status = combined_status / objectives.count()
    else:
      objectivesRating = 0
      average_status = 0
    objectivesRating = ((objectivesRating * 2) + (average_status))/3
    
    overallRating = (tasksRating + (deliverablesRating * 2) + (objectivesRating * 3)) / 6

    wellDone = False;
    warning = False;
    if overallRating > 0:
      wellDone = True
    elif overallRating < 0:
      warning = True

    return {'type': type,
            'bad_tasks_count': badTasksCount,
            'tasks_rating': tasksRating,
            'bad_deliverables_count': badDeliverablesCount,
            'good_deliverables_count': goodDeliverablesCount,
            'deliverables_rating': deliverablesRating,
            'objectives_count': objectives.count(),
            'good_objectives_count': goodObjectivesCount,
            'bad_objectives_count' : badObjectivesCount,
            'objectives_rating': objectivesRating,
            'overall_rating': overallRating,
            'well_done': wellDone,
            'warning': warning}
